package com.lvw.hadoop.spring;

import com.lvw.hadoop.project.LogApp;
import org.apache.hadoop.fs.FileStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.hadoop.fs.FsShell;

import java.util.Collection;

/**
 * Run hadoop command using Spring Boot.
 * 使用到的文件: application.properties
 */
@SpringBootApplication
public class SpringHadoopBootApp implements CommandLineRunner {

    @Autowired
    FsShell shell;

    @Override
    public void run(String... strings) throws Exception {
        Collection<FileStatus> ls = shell.ls("/");
        for (FileStatus file : ls) {
            System.out.println(file.getPath());
        }
    }

    public static void main(String[] args) {
        SpringApplication.run(SpringHadoopBootApp.class, args);
    }
}
